package com.yfqy.app.modules.banner.resource;

import com.yfqy.app.domain.vo.ResultVO;
import com.yfqy.app.modules.banner.service.BannerService;
import com.yfqy.app.modules.banner.vo.BannerVO;
import com.yfqy.app.modules.product.vo.ProductSpuVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/client")
public class BannerController {

    @Autowired
    private BannerService bannerService;

    /**
     * 轮播图接口
     *
     * @return
     */
    @GetMapping("/public/banners")
    public ResultVO<List<BannerVO>> getAllBanners() {
        return ResultVO.data(bannerService.getAllBanners());
    }

    /**
     * 查看轮播图绑定的商品
     *
     * @param id
     * @return
     */
    @GetMapping("/getSpuDetailByBanner/{id}")
    public ResultVO<ProductSpuVO> getSpuDetailByBanner(@PathVariable Long id) {
        return ResultVO.data(bannerService.getSpuDetailByBanner(id));
    }


}
